import axios from 'axios'
import { message } from 'ant-design-vue'
const instance = axios.create({
    // baseURL: 'http://192.168.52.13:8080',
    baseURL:'http://localhost:8080',
    timeout: 300000
})


instance.interceptors.request.use(config => {
    return config
}, error => {
    return Promise.reject(error)
})

instance.interceptors.response.use(response => {
    if(response.data.type == 'application/octet-stream'){
        return response.data
    }
    if(response.data.code === 200 || response.data.type == 'application/octet-stream'){
        return response.data.data
    }else{
        return Promise.reject(response.data.message)
    }
}, error => {
    console.log('错误',error)
    const err = error.response.data.msg
    message.error(err)
    return Promise.reject(err)
})

export default instance